/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Interface;

import Biz.PatientBO;
import Entity.Patient;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;

/**
 *
 * @author cgzf
 */
public class Frame_Patient extends javax.swing.JFrame {

    /**
     * Creates new form NewJFrame
     */
    public Frame_Patient() {
        initComponents();
        ImageIcon search = new ImageIcon("icon3.jpg");
        ImageIcon top = new ImageIcon("test1.png");
        ImageIcon mail = new ImageIcon("mailbox.png");
        ImageIcon logout = new ImageIcon("logout.png");
        ImageIcon report = new ImageIcon("report.png");
        ImageIcon account = new ImageIcon("account.png");
        //lblSearch.setIcon(search);
        //pnlPatient.setVisible(true);
        //jPanel1.setVisible(false);

    }

    public void disableAll() {
        pnlReport.setVisible(false);
        pnlMyAccount.setVisible(false);
        pnlTest.setVisible(false);
        pnlBilling.setVisible(false);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLayeredPane1 = new javax.swing.JLayeredPane();
        pnlReport = new javax.swing.JPanel();
        pnlMyAccount = new javax.swing.JPanel();
        pnlTest = new javax.swing.JPanel();
        pnlBilling = new javax.swing.JPanel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu4 = new javax.swing.JMenu();
        jMenu5 = new javax.swing.JMenu();
        jMenu6 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();
        jMenu1 = new javax.swing.JMenu();
        jMenu7 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        javax.swing.GroupLayout pnlReportLayout = new javax.swing.GroupLayout(pnlReport);
        pnlReport.setLayout(pnlReportLayout);
        pnlReportLayout.setHorizontalGroup(
            pnlReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 750, Short.MAX_VALUE)
        );
        pnlReportLayout.setVerticalGroup(
            pnlReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 510, Short.MAX_VALUE)
        );

        pnlReport.setBounds(0, -50, 750, 510);
        jLayeredPane1.add(pnlReport, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout pnlMyAccountLayout = new javax.swing.GroupLayout(pnlMyAccount);
        pnlMyAccount.setLayout(pnlMyAccountLayout);
        pnlMyAccountLayout.setHorizontalGroup(
            pnlMyAccountLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 740, Short.MAX_VALUE)
        );
        pnlMyAccountLayout.setVerticalGroup(
            pnlMyAccountLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 420, Short.MAX_VALUE)
        );

        pnlMyAccount.setBounds(0, 0, 740, 420);
        jLayeredPane1.add(pnlMyAccount, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout pnlTestLayout = new javax.swing.GroupLayout(pnlTest);
        pnlTest.setLayout(pnlTestLayout);
        pnlTestLayout.setHorizontalGroup(
            pnlTestLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 760, Short.MAX_VALUE)
        );
        pnlTestLayout.setVerticalGroup(
            pnlTestLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 440, Short.MAX_VALUE)
        );

        pnlTest.setBounds(0, 0, 760, 440);
        jLayeredPane1.add(pnlTest, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout pnlBillingLayout = new javax.swing.GroupLayout(pnlBilling);
        pnlBilling.setLayout(pnlBillingLayout);
        pnlBillingLayout.setHorizontalGroup(
            pnlBillingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 810, Short.MAX_VALUE)
        );
        pnlBillingLayout.setVerticalGroup(
            pnlBillingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 430, Short.MAX_VALUE)
        );

        pnlBilling.setBounds(0, 0, 810, 430);
        jLayeredPane1.add(pnlBilling, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jMenu4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Picture/Lab.png"))); // NOI18N
        jMenu4.setText("Register Test");
        jMenu4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jMenu4MouseClicked(evt);
            }
        });
        jMenuBar1.add(jMenu4);

        jMenu5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Picture/Report.png"))); // NOI18N
        jMenu5.setText("My Report");
        jMenu5.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jMenu5MouseClicked(evt);
            }
        });
        jMenuBar1.add(jMenu5);

        jMenu6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Picture/Billing.png"))); // NOI18N
        jMenu6.setText("My Billing");
        jMenu6.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jMenu6MouseClicked(evt);
            }
        });
        jMenuBar1.add(jMenu6);

        jMenu2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Picture/Account.png"))); // NOI18N
        jMenu2.setText("My Account");
        jMenuBar1.add(jMenu2);

        jMenu1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Picture/Help.png"))); // NOI18N
        jMenu1.setText("Help");
        jMenuBar1.add(jMenu1);

        jMenu7.setIcon(new javax.swing.ImageIcon("C:\\Users\\cgzf\\Documents\\Project\\Project\\logout.png")); // NOI18N
        jMenu7.setText("Logout");
        jMenu7.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jMenu7MouseClicked(evt);
            }
        });
        jMenuBar1.add(jMenu7);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 880, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(60, 60, 60)
                .addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 516, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(44, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jMenu4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenu4MouseClicked
        try {
            disableAll();
            pnlTest.setVisible(true);
            Patient_ViewTest pvt = new Patient_ViewTest();
            pnlTest.add(pvt);
            pvt.setSize(pnlReport.getSize());
            pvt.setVisible(true);
        } catch (SQLException ex) {
            Logger.getLogger(Frame_Patient.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jMenu4MouseClicked

    private void jMenu5MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenu5MouseClicked
        try {
            disableAll();
            pnlReport.setVisible(true);
            Patient_ViewReport pvt = new Patient_ViewReport();
            pnlReport.add(pvt);
            pvt.setSize(pnlReport.getSize());
            pvt.setVisible(true);
        } catch (SQLException ex) {
            Logger.getLogger(Frame_Patient.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_jMenu5MouseClicked

    private void jMenu6MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenu6MouseClicked
        try {
            disableAll();
            pnlBilling.setVisible(true);
            Patient_ViewBilling pvt = new Patient_ViewBilling();
            pnlBilling.add(pvt);
            pvt.setSize(pnlBilling.getSize());
            pvt.setVisible(true);
        } catch (SQLException ex) {
            Logger.getLogger(Frame_Patient.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_jMenu6MouseClicked

    private void jMenu7MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenu7MouseClicked
        try {
            for (Patient p : new PatientBO().getPatient()) {
                 if (p.isStatus() == true) {
                      new PatientBO().UpdatePatientStatus(p.getPatientID(), false);
                 }
             }
         Frame_Login fl = new Frame_Login();
         this.setVisible(false);
         fl.setVisible(true);
        } catch (SQLException ex) {
            Logger.getLogger(Frame_Patient.class.getName()).log(Level.SEVERE, null, ex);
        }
     
       


    }//GEN-LAST:event_jMenu7MouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Frame_Patient.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Frame_Patient.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Frame_Patient.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Frame_Patient.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Frame_Patient().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenu jMenu5;
    private javax.swing.JMenu jMenu6;
    private javax.swing.JMenu jMenu7;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel pnlBilling;
    private javax.swing.JPanel pnlMyAccount;
    private javax.swing.JPanel pnlReport;
    private javax.swing.JPanel pnlTest;
    // End of variables declaration//GEN-END:variables
}
